package com.zjw.zy.coreui.fragment

import com.zjw.zy.base.BaseFragment
import android.os.Bundle
import android.view.View
import android.view.ViewGroup
import android.webkit.WebView
import com.zjw.zy.R
import com.zjw.zy.ext.open
import com.zjw.zy.ext.release
import com.zjw.zy.utils.WindowUtils

class BrowserFragment : BaseFragment() {

    private val webView: WebView by lazy { findViewById(R.id.browser_web_view) }
    override fun onPageEnter() {
        WindowUtils.TopBar.showBack()
        WindowUtils.FootBar.hide()

        webView.open("https://www.baidu.com/", true)
    }

    override fun onViewRestore(savedInstanceState: Bundle?) {}
    override fun onSubscribe() {}
    override fun onBindViewListener() {}
    override fun onBindViewValue() {
    }

    override fun onFindView(rootView: View) {}
    override fun onLayoutId(): Int {
        return R.layout.fragment_browser
    }

    override fun onPageExit() {
        webView.release()
    }

    override fun onBackClick() {
        if (webView.canGoBack()) {
            webView.goBack()
            return
        }
        super.onBackClick()
    }
}